package Static_;

public class static_ {
    public static void main(String[] args) {
        child child1 = new child("1");
        child1.join();
        child1.count++;

        child child2 = new child("2");
        child2.join();
        child2.count++;

        child child3 = new child("3");
        child3.join();
        child3.count++;

        System.out.println("共有" + child.count + "个小孩加入了游戏..");

    }
}

class child{
    private String name;

    //定义一个变量count，是一个类变量(静态变量)
    //该变量会被child类的虽有对象实例共享
    public static int count = 0;

    public child(String name) {
        this.name = name;
    }
    public void join(){
        System.out.println(name + "加入了游戏...");
    }
}
